package com.haima.sage.bigdata.api.frame.condition;


import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
import com.haima.sage.bigdata.api.frame.condition.impl.ConditionService;

@JsonTypeInfo(use = Id.NAME,
        include = As.EXISTING_PROPERTY,
        property = "operator",
        defaultImpl = ConditionItem.class,
        visible = true)
@JsonSubTypes({
        @Type(value = ConditionGroup.class, name = "and"),
        @Type(value = ConditionGroup.class, name = "or"),
        @Type(value = ConditionGroup.class, name = "not")})
public abstract class Condition<T extends ConditionService<?>> {
    private OperatorType operator;

    public abstract T service();

    public OperatorType getOperator() {
        return operator;
    }

    public void setOperator(OperatorType operator) {
        this.operator = operator;
    }
}
